<?php
/*
 * Copyright (C) 2009 Jeffrey Palm
 */

   /* ============================================================
   * README
   * The following have to be defined:
   * - TITLE              Name of the meeting
   * - LONGITUDE_START    Longitude coord on which we start
   * - LATITUDE_START     Latitude  coord on which we start
   * ============================================================
   */

   if (!defined('BASE')) {
     define('BASE','../');
   }

require_once BASE . 'config.php';
include_once BASE . 'session.php';

// For the IPhone just do a list of locations
require_once BASE . 'util.php';

if (isIPhone()) {
  //
  // These have to be single quotes, because they will be surrounded
  // by double quotes in iphone_head.php
  //
  $ON_LOAD = 'onLoad(\'' . $_REQUEST['q'] . '\')';
  define('INCLUDE_JS',TRUE);
  include BASE . 'iphone_head.php';
  include BASE . 'iphone_foot.php';
  return;
 }

if (isAlphabetical()) {
  include BASE . 'menu_head_content.php';
  include BASE . 'alphabetical.php';
  include BASE . 'menu_foot_content.php';
  return;
 }

if (isTable()) {
  include BASE . 'menu_head_content.php';
  include BASE . 'table.php';
  include BASE . 'menu_foot_content.php';
  return;
 }

if (isSearch()) {
  include BASE . 'menu_head_content.php';
  include BASE . 'search.php';
  include BASE . 'menu_foot_content.php';
  return;
 }

// For the 'list' param just do a list of locations
// TODO: Why isn't this working?
if (FALSE && isList()) {
  include BASE . 'main.php';
  include BASE . 'menu_foot.php';
  return;
 }

   ?>
<html>
  <head>
<script type="text/javascript">
<?php
  // Variables for javascript
  echo 'var ONLOAD_ANIMATE_DAY = '  . (isset($_REQUEST['animateDay'])  ? 'true' : 'false') . ';';
  echo 'var ONLOAD_ANIMATE_WEEK = ' . (isset($_REQUEST['animateWeek']) ? 'true' : 'false') . ';';
?>
</script>
<title><?php echo NAME_CAPS . ' :: '; if (TITLE) echo TITLE . ' '; ?><?php echo NAME; ?></title>
    <link rel="stylesheet" href="<?php echo BASE; ?>css/main.css" type="text/css" media="screen">

  <?php if (useMap()) { ?>
    <link rel="stylesheet" href="<?php echo BASE; ?>css/map.css" type="text/css" media="screen">
  <?php } ?>

  <?php if (useMap()) { ?>
    <script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo GOOGLE_MAPS_KEY; ?>" type="text/javascript"> </script>
        <?php } ?>
        
		<script type="text/javascript" src="<?php echo BASE; ?>js/prototype.js"></script>
	  <script type="text/javascript">
      CITY = "<?php echo TITLE; ?>";
      STATE = "<?php echo basename(dirname(dirname($_SERVER['SCRIPT_FILENAME']))); ?>";
      GOOGLE_MAPS_KEY = "<?php echo GOOGLE_MAPS_KEY; ?>";
      BASE_DIR = "<?php echo BASE; ?>";
      LONGITUDE_START = "<?php echo LONGITUDE_START; ?>";
      LATITUDE_START = "<?php echo LATITUDE_START; ?>";
    </script>
    <script type="text/javascript" src="<?php echo BASE; ?>js/latlon.js" ></script>
    <script type="text/javascript" src="<?php echo BASE; ?>js/main.js" ></script>
  </head>
  <body onLoad="onLoad(); return false">

    <div id="top" style="width:90%; height:9%; margin:2px">

      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td>

            <span id="maptitle">
        <?php echo TITLE; ?> <?php echo NAME; ?>
            </span>
            
            <select id="daySelect" onChange="resetMarkers(); return false">
              <option value="0">Sun</option>
              <option value="1">Mon</option>
              <option value="2">Tue</option>
              <option value="3">Wed</option>
              <option value="4">Thu</option>
              <option value="5">Fri</option>
              <option value="6">Sat</option>
            </select>

            <select id="hourSelect" onChange="resetMarkers(); return false">
              <option value="0">12:00a</option>
              <option value="1">12:30a</option>
              <option value="2">1:00a</option>
              <option value="3">1:30a</option>
              <option value="4">2:00a</option>
              <option value="5">2:30a</option>
              <option value="6">3:00a</option>
              <option value="7">3:30a</option>
              <option value="8">4:00a</option>
              <option value="9">4:30a</option>
              <option value="10">5:00a</option>
              <option value="11">5:30a</option>
              <option value="12">6:00a</option>
              <option value="13">6:30a</option>
              <option value="14">7:00a</option>
              <option value="15">7:30a</option>
              <option value="16">8:00a</option>
              <option value="17">8:30a</option>
              <option value="18">9:00a</option>
              <option value="19">9:30a</option>
              <option value="20">10:00a</option>
              <option value="21">10:30a</option>
              <option value="22">11:00a</option>
              <option value="23">11:30a</option>
              <option value="24">12:00p</option>
              <option value="25">12:30p</option>
              <option value="26">1:00p</option>
              <option value="27">1:30p</option>
              <option value="28">2:00p</option>
              <option value="29">2:30p</option>
              <option value="30">3:00p</option>
              <option value="31">3:30p</option>
              <option value="32">4:00p</option>
              <option value="33">4:30p</option>
              <option value="34">5:00p</option>
              <option value="35">5:30p</option>
              <option value="36">6:00p</option>
              <option value="37">6:30p</option>
              <option value="38">7:00p</option>
              <option value="39">7:30p</option>
              <option value="40">8:00p</option>
              <option value="41">8:30p</option>
              <option value="42">9:00p</option>
              <option value="43">9:30p</option>
              <option value="44">10:00p</option>
              <option value="45">10:30p</option>
              <option value="46">11:00p</option>
              <option value="47">11:30p</option>
            </select>

            <span>&nbsp;&nbsp;&nbsp;</span>

            <span id="legend">
              <img src="<?php echo BASE; ?>img/icong.png" /> &lt;= 2 hours
              &nbsp;&nbsp;
              <img src="<?php echo BASE; ?>img/iconb.png" /> &lt;= 3 hours
              &nbsp;&nbsp;
              <img src="<?php echo BASE; ?>img/iconr.png" /> &lt;= 4 hours
            </span>

            <!--
                <span id="animate-legend">
                  Animate by
              <a id="animateDayEl" href="#" onclick="animateDay()">day</a>
              |
              <a id="animateWeekEl" href="#" onclick="animateWeek()">week</a>
                </span>
                -->

          </td>
          <td align="right">

            <div>
              <span id="msg"></span>
              <br/>
              <a href="<?php echo BASE; ?>">Home</a> |
              <a href="../">
                      <?php echo basename(dirname(dirname($_SERVER['SCRIPT_FILENAME']))); ?>
              </a> |
              <a href="<?php phpSelf(); ?>?alphabetical">List</a> |
                      <a href="<?php phpSelf(); ?>?iphone">IPhone</a> |
                      <a href="<?php phpSelf(); ?>?table">Table</a> |
                      <a href="<?php phpSelf(); ?>?search">Search</a> |
                      <a href="<?php phpSelf(); ?>?normal">Normal</a>
            </div>
            <div id="search">
              <form onsubmit="doSearch(); return false">
              <input type="text" style="width:25em;margin-top:0px" value="" name="q" id="q"></input>
              <input type="submit" value="Search"></input>
            </div>
            
          </td>
        </tr>
      </table>

    </div>

    <div id="map" style="width:100%; height:91%"></div>

  </body>
</html>
